package main

import (
	"fmt"
)


func writeData(intChan chan int) {
	for i:=1;i<=100;i++{
		intChan <- i
		fmt.Println("写数据", i)
	}
	close(intChan)
}

func readData(intChan chan int, exitChan chan bool) {
	for v := range intChan{
		fmt.Println("读取数据", v)
	}
	exitChan <- true
	close(exitChan)
}

func main() {
	var intChan = make(chan int,100)
	var exitChan = make(chan bool,1)
	go writeData(intChan)
	go readData(intChan, exitChan)
	for {
		_, flag := <- exitChan
		if !flag{
			break
		}
	}
	//for v := range exitChan{
	//	if !v {
	//		break
	//	}
	//}
	fmt.Println("main...")
}
